package com.xjc.infra.util;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

/**
 * servlet 工具类
 * @author liangcz
 * @Date   2018年1月11日 上午10:05:59
 * @version 1.0
 */
public class ServletUtil {
	/**
	 * 获取当前线程  servlet request
	 * @author liangcz
	 * @date   2018年1月11日 上午10:07:19
	 * @return HttpServletRequest
	 */
	public static HttpServletRequest getHttpServletRequest(){
		HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder
				.getRequestAttributes()).getRequest();
		return request;
	}
	/**
	 * 获取当前线程 servlet response
	 * @author liangcz
	 * @date   2018年1月11日 上午10:08:35
	 * @return HttpServletResponse
	 */
	public static HttpServletResponse getHttpServletResponse(){
		HttpServletResponse response = ((ServletRequestAttributes) RequestContextHolder
				.getRequestAttributes()).getResponse();
		return response;
	}
}
